<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<style>
			#shopEditForm .form-item {margin-bottom: 20px; width: 50%; float: left;}
			#shopEditForm .form-item>label{min-width: 86px; display: inline-block; text-align: right;}
			
			.banner-images{display: flex; overflow: auto;}
			.banner-images img.td-img{max-width: 60px; margin:0 2px; border: 1px solid #333;}
			
			.second-nav-split > ul{width: 100%; display: flex; flex-flow: row wrap;}
			.second-nav-split > ul > li{width: 20% !important; display: inline-block; position: relative; box-sizing: border-box; padding: 6px; margin: 4px 0px;text-align: center;}
			.second-nav-split > ul > li:hover{cursor: pointer;}
			.second-nav-split > ul > li:not(.add):hover{border: 1px solid #0080ff;}
			.second-nav-split > ul > li.active{border: 1px solid #0080ff; color: #0080ff;}
			.second-nav-split > ul > li.no-present{opacity: 0.5;}
			.second-nav-split > ul > li > img{width: 100%; max-width: 80%;}
			.second-nav-split > ul > li > span{display: inline-block; width: 100%; text-align: center; font-size: 12px;}
			.second-nav-split > ul > li > a.second-nav-delete{background: url(dists/super/images/tabs_icons.png) no-repeat -34px center; width: 12px; height: 12px; position: absolute; top: 4px; right: 4px;}
			
			.second-nav-content > ul{width: 100%; display: flex; flex-flow: row wrap;}
			.second-nav-content > ul > li{width: 100% !important; display: inline-block; position: relative; box-sizing: border-box; margin: 4px 0px;text-align: center; border: 1px solid #CFCFCF;}
			.second-nav-content > ul > li:hover{cursor: pointer; border: 1px solid #0080ff;}
			.second-nav-content > ul > li.active{border: 1px solid #0080ff; color: #0080ff;}
			.second-nav-content > ul > li > img{width: 100%; max-width: 100%;}
			.second-nav-content > ul > li > a.second-nav-delete{background: url(dists/super/images/tabs_icons.png) no-repeat -34px center; width: 12px; height: 12px; position: absolute; top: 8px; right: 8px;}
			.second-nav-content > ul > li > span.module-info{position: absolute; top: 8px; left: 8px; font-size: 16px; font-weight: bold;}
			.second-nav-content > ul > li > span.module-contains{background: rgba(0, 0, 0, 0.3); position: absolute; bottom: 0px; left: 0; right: 0; padding: 6px; box-sizing: border-box;}
			.second-nav-content > ul > li > span.module-contains > strong{font-size: 14px;}
			
			#shop-nav-edit-form .form-item {margin-bottom: 20px; width: 50%; float: left;}
			#shop-nav-edit-form .form-item>label{min-width: 72px; display: inline-block; text-align: right;}
			#shop-nav-edit-form .form-item > img{width: 80px;}
			
			.edit-title{display: inline-block; font-weight: bold; margin: 8px 0px; width: 100%; border-bottom: 1px solid #cecece;}
			.tabs li a.tabs-close, .tabs-p-tool{height: 14px; margin-top: -10px;}

			.shop-factory{display: flex;align-items: center; justify-content: space-between; height: 100%; width: 100%;}
			.shop-factory > div{height: 100%;}
			.shop-factory .shop-factory-pageview{flex: 1; border-left: 1px solid #333;padding: 0 20px;}
			.shop-factory .shop-factory-pageview div{display: block;font-size: 14px;padding: 23px; text-align: center;}
			.shop-factory .shop-factory-pageview iframe{width: 500px; height: 812px; box-shadow: 0 0px 4px 0px #bbb;margin: 0 auto;display: block;margin-bottom: 20px; margin-top: 8px;}
			.shop-factory > div:first-child{display: flex; align-items: center; justify-content: center; flex-direction: column;}
			.shop-factory .shop-factory-mes{padding: 20px;}
			.shop-factory .shop-factory-page{width: 500px; height: 812px; box-shadow: 0 0px 4px 0px #bbb;margin: 0 auto;position: relative;margin-top: 20px;display: flex;flex-direction: column;}
			.shop-factory .shop-factory-page .shop-factory-tools{position: absolute;right: -50px; width: 50px; box-shadow: 2px 2px 6px 0px #bbb; border-radius: 4px; overflow: hidden;}
			.shop-factory .shop-factory-page .shop-factory-tools > div{display: none;height: 100%;font-size: 0;}
			.shop-factory .shop-factory-page .shop-factory-tools > div span{display: block;width: 50px; height: 50px;font-size: 14px;line-height: 50px;text-align: center;cursor: pointer;}
			.shop-factory .shop-factory-page .shop-factory-tab{height: 56px;box-shadow: 0 1px 2px 0px #bbb;overflow-x: scroll;}
			.shop-factory .shop-factory-page .shop-factory-tab ul{width: max-content; height: 100%;display: flex; flex-wrap: nowrap;min-width: 100%;}
			.shop-factory .shop-factory-page .shop-factory-tab ul li{padding: 0 8px;height: 40px;line-height: 40px;color: rgba(0, 0, 0, .6);cursor: pointer;position: relative;min-width: 56px; text-align: center;border-radius: 4px;margin: 3px 6px 3px 0;}
			.shop-factory .shop-factory-page .shop-factory-tab ul div{height: 40px;line-height: 40px;color: rgba(0, 0, 0, .6);cursor: pointer;width: 100%; text-align: center;}
			.shop-factory .shop-factory-page .shop-factory-tab ul li.shop-factory-tab-hide{background: #e5e5e5;}
			.shop-factory .shop-factory-page .shop-factory-tab ul li.active{color: #FF3450;}
			.shop-factory .shop-factory-page .shop-factory-tab ul li.active::before{content:'';width:12px;height:6px;display:block;margin-right:4px;position:absolute;left:2px;bottom:6px;border-radius:2px;border-bottom:2px solid #ff3450;border-left:2px solid #ff3450}
			.shop-factory .shop-factory-page .shop-factory-tab ul li.active::after{content:'';width:12px;height:6px;display:block;margin-left:4px;position:absolute;right:2px;top:6px;border-radius:2px;border-top:2px solid #ff3450;border-right:2px solid #ff3450}
			.shop-factory .shop-factory-page .shop-factory-container{flex: 1;overflow-y: scroll;}
			.shop-factory .shop-factory-page .shop-factory-nav{display:flex;align-items:center;padding:0;margin:4px 3px 0 3px;margin-top:0;box-sizing:border-box;flex-wrap:wrap; min-height: 73px;}
			.shop-factory .shop-factory-page .shop-factory-nav div{width: 100%; text-align: center;cursor: pointer;line-height: 72px;}
			.shop-factory .shop-factory-page .shop-factory-nav li{width: calc(20% - 4px);display:block;color:#000;text-align:center;background:#fff;box-sizing:border-box;text-decoration:none;border-radius:4px;position: relative;margin: 2px;cursor: pointer}
			.shop-factory .shop-factory-page .shop-factory-nav li.shop-factory-tab-hide{background: #e5e5e5;}
			.shop-factory .shop-factory-page .shop-factory-nav li.active{color: #FF3450;}
			.shop-factory .shop-factory-page .shop-factory-nav li.active::before{content:'';width:12px;height:6px;display:block;margin-right:4px;position:absolute;left:2px;bottom:6px;border-radius:2px;border-bottom:2px solid #ff3450;border-left:2px solid #ff3450}
			.shop-factory .shop-factory-page .shop-factory-nav li.active::after{content:'';width:12px;height:6px;display:block;margin-left:4px;position:absolute;right:2px;top:6px;border-radius:2px;border-top:2px solid #ff3450;border-right:2px solid #ff3450}
			.shop-factory .shop-factory-page .shop-factory-nav li img{width:40px;height:40px;border-radius:50%;overflow:hidden;margin:0 auto;display:block;transform:translateY(8px)}
			.shop-factory .shop-factory-page .shop-factory-nav li span{font-size:12px;display:block;border-radius:6px;padding:10px 4px 4px 4px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
			.shop-factory .shop-factory-page .shop-factory-module{background: #f4f4f4;min-height: 683px;}
			.shop-factory .shop-factory-page .shop-factory-module ul > div{width: 100%;text-align: center; padding: 40px 0; cursor: pointer;}
			.shop-factory .shop-factory-page .shop-factory-module li{position: relative;margin-bottom: 4px; cursor: pointer;}
			.shop-factory .shop-factory-page .shop-factory-module li img{width: 100%;}
			.shop-factory .shop-factory-page .shop-factory-module li div{width: 100%;height: 100%; position: absolute; top: 0; left: 0; background: rgba(0,0,0,.3);color: #fff;padding: 6px 10px;box-sizing: border-box;}
			.shop-factory .shop-factory-page .shop-factory-module li p{font-size: 14px;}
			.shop-factory .shop-factory-page .shop-factory-module li.active div{background: rgba(255, 84, 48, 0.64);}
			.shop-factory-tab::-webkit-scrollbar {width: 1px;height: 10px;}
			.shop-factory-tab::-webkit-scrollbar-thumb {border-radius: 10px;box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);background: #535353;}
			.shop-factory-tab::-webkit-scrollbar-track {box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);border-radius: 10px;background: #ededed;}
			.shop-factory-container::-webkit-scrollbar {width: 10px;height: 1px;}
			.shop-factory-container::-webkit-scrollbar-thumb {border-radius: 10px;box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);background: #535353;}
			.shop-factory-container::-webkit-scrollbar-track {box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);border-radius: 10px;background: #ededed;}
		</style>
		<div class="super-theme-example">
			<div class="options-toolbar" style="justify-content: flex-end;">
				<div class="top-options">
					<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fa fa-refresh'" onclick="app_shop.methods.queryDatagrid();">刷新</a>
					<a href="javascript:void(0)" class="easyui-linkbutton success" data-options="iconCls:'fa fa-plus'" onclick="app_shop.methods.openCreateShopWindow();">新建</a>
				</div>
			</div>
			<table id="shop-datagrid"></table>
			<div id="shopEditWin" class="easyui-window" title="创建商城" style="width:700px;height:800px" data-options="modal:true,closed:true,minimizable:false,maximizable:false">
				<div class="super-theme-example">
					<form id="shopEditForm">
						<input name="id" type="hidden" />
						<div class="form-item">
							<label for="" class="label-top">名称：</label>
							<input name="name" class="easyui-textbox" style="width: 230px;" prompt="名称...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">地址：</label>
							<input name="location" class="easyui-textbox" style="width: 230px;" prompt="地址...">
						</div>
						
						<div class="form-item">
							<label for="" class="label-top">包邮价格：</label>
							<input name="basicPrice" class="easyui-numberbox" style="width: 68px;" prompt="包邮价格...">
							<label for="" class="label-top">运费：</label>
							<input name="freight" class="easyui-numberbox" style="width: 68px;" prompt="运费...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">币种符号：</label>
							<input name="currencySymbol" class="easyui-textbox" style="width: 68px;" prompt="符号($)...">
							<label for="" class="label-top">币种：</label>
							<input name="currency" class="easyui-textbox" style="width: 68px;" prompt="币种(TWD)...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">订单前缀：</label>
							<input name="prefix" class="easyui-textbox" style="width: 68px;" prompt="订单前缀...">
							<label for="" class="label-top">币种：</label>
							<input name="country" class="easyui-textbox" style="width: 68px;" prompt="国家...">
						</div>
						<div class="form-item" style="display: none;">
							<label for="" class="label-top">汇率：</label>
							<input name="exchangeRate" class="easyui-textbox" style="width: 230px;" value="1" prompt="汇率...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">备注：</label>
							<input name="comments" class="easyui-textbox" style="width: 230px;" prompt="comments...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">fbPiexId：</label>
							<input name="fbPiexId" class="easyui-textbox" style="width: 230px;" prompt="FB像素...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">fbMessageId：</label>
							<input name="fbMessageId" class="easyui-textbox" style="width: 230px;" prompt="fb Message...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">addresses：</label>
							<input name="addressBase" class="easyui-textbox" multiline="true" style="width: 230px; height: 60px;" prompt="地址库...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">languages：</label>
							<input name="languageBase" class="easyui-textbox" multiline="true" style="width: 230px; height: 60px;" prompt="多语言...">
						</div>
						
					</form>
					
					
					<span class="edit-title">关于我们</span>
					<div id="aboutUs"></div>
					
					<span class="edit-title">隐私条款</span>
					<div id="privacyPolicy"></div>
					
					<span class="edit-title">退换货政策</span>
				    <div id="exchangePolicy"></div>
				    
				    <span class="edit-title">常见问题</span>
				    <div id="problems"></div>
					
					<div style="text-align: right; box-sizing: border-box;padding: 10px;">
						<a href="#" class="easyui-linkbutton" style="width: 80px;" onclick="$('#shopEditWin').window('close');">取消</a>
						<a href="#" class="easyui-linkbutton primary" style="width: 80px;" onclick="app_shop.methods.createShop();">保存</a>
					</div>
				</div>
			</div>
			
			<!-- 商城绑定模块 -->
			<div id="shopNavWin" class="easyui-window" title="商城工厂" data-options="modal:true,minimizable:false,maximizable:false,maximized:true,closed:true">
				<div class="shop-factory">
					<div>
						<div class="shop-factory-page">
							<div class="shop-factory-tab">
								<ul></ul>
							</div>
							<div class="shop-factory-container">
								<ul class="shop-factory-nav"></ul>
								<div class="shop-factory-module"></div>
							</div>
							<div class="shop-factory-tools">
								<div class="shop-factory-tools-0">
									<span class="fa fa-plus-circle" onclick="app_shop.shopnav.plusShopNav()"></span>
									<span class="fa fa-copy" onclick="app_shop.shopnav.copyShopNavLink()"></span>
									<span class="fa fa-chrome" onclick="app_shop.shopnav.openView()"></span>
									<span class="fa fa-cog" onclick="app_shop.shopnav.editShopNav()"></span>
									<span class="fa fa-trash-o" onclick="app_shop.shopnav.deleteShopNav()"></span>
								</div>
								<div class="shop-factory-tools-1">
									<span class="fa fa-plus-circle" onclick="app_shop.shopnav.plusSecondNav(0)"></span>
									<!-- <span class="fa fa-chrome" onclick="app_shop.shopnav.openView()"></span> -->
									<span class="fa fa-cog" onclick="app_shop.shopnav.plusSecondNav(1)"></span>
									<span class="fa fa-trash-o" onclick="app_shop.shopnav.deleteSecondNav()"></span>
								</div>
								<div class="shop-factory-tools-2">
									<span class="fa fa-plus-circle" onclick="app_shop.shopnav.addNavModule()"></span>
									<span class="fa fa-cog" onclick="app_shop.shopnav.priorityNavModule()"></span>
									<span class="fa fa-trash-o" onclick="app_shop.shopnav.deleteNavModule()"></span>
								</div>
							</div>
						</div>
						<div class="shop-factory-mes">
							<p>Tips:</p>
							<p>一级导航说明：所有商城需要手动默认设置第一个导航为“首页”（展示），第二个导航为“热卖”（不展示）</p>
							<p>二级导航渲染规则：默认展示所有设置为“不展示”的模块</p>
						</div>
					</div>
					<div class="shop-factory-pageview">
						<iframe src="" frameborder="0"></iframe>
						<p>Tips:</p>
						<p>由于缓存问题，预览界面中的导航不会随着编辑而改变。如果想查看导航，请点击复制按钮后手动打开新标签页查看。</p>
					</div>
				</div>
			</div>
			
			<div id="shopNavEdit" class="easyui-dialog" title="编辑" style="width:600px;height:400px;" data-options="modal:true,closed:true,buttons:'#shopNavEdit-buttons'">
			    <div class="super-theme-example">
			    	<form id="shop-nav-edit-form">
			    		<div class="form-item">
							<label for="" class="label-top">名称：</label>
							<input name="name" class="easyui-textbox" data-options="required:true" style="width: 180px;" prompt="名称...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">优先级：</label>
							<input name="priority" class="easyui-numberbox" data-options="required:true" value="0" style="width: 180px;" prompt="优先级...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">是否显示：</label>
							<input name="isShow" id="nav-switchbutton" class="easyui-switchbutton" data-options="onText:'显示',offText:'不显示'" checked style="width: 180px;">
						</div>
						<div class="form-item">
							<label for="" class="label-top">备注：</label>
							<input name="comments" class="easyui-textbox" data-options="multiline:true" style="width: 180px;" prompt="备注...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">缩略图：</label>
							<img class="mav-thumb" src="" style="cursor: pointer;" />
						</div>
						<input type="hidden" name="id" />
						<input type="hidden" name="parentId" />
			    	</form>
			    </div>
			</div>

			<div id="shopNavEdit-buttons">
				<a href="#" class="easyui-linkbutton" onclick="app_shop.shopnav.saveNavEdit()">保存</a>
				<a href="#" class="easyui-linkbutton" onclick="$('#shopNavEdit').dialog('close');">取消</a>
			</div>
			
			<button type="button" id="navThumbUpload" style="display: none;"></button>
		</div>
		
		<div id="navAddModuleWin" class="easyui-window" title="绑定模块" style="width:1000px;height:700px" data-options="closed:true,modal:true,minimizable:false,maximizable:false,tools:[{iconCls:'fa fa-save',handler:function(){app_shop.shopnav.persitsNavModules();}}]">
			<div class="super-theme-example">
				<div class="options-toolbar">
					<form id="navModuleQueryParams">
						<input class="easyui-textbox" name="collectionId" data-options="width:120,prompt:'模块ID...'">
						<input class="easyui-textbox" name="name" data-options="width:150,prompt:'模块名称...'">
						<input class="easyui-textbox" name="comments" data-options="width:150,prompt:'模块备注...'">
						<a href="javascript:void(0)" class="easyui-linkbutton primary" data-options="iconCls:'fa fa-search'" onclick="$('#navModuleDatagrid').datagrid('load',$('#navModuleQueryParams').serializeJson());">查询</a>
					</form>
				</div>
				<table id="navModuleDatagrid"></table>
			</div>
		</div>
		
		<script src="dists/wangEditor/release/wangEditor.js"></script>
		<script type="text/javascript" src="dists/plupload-2.3.6/js/plupload.full.min.js"></script>
		<script type="text/javascript" src="dists/plupload-2.3.6/js/i18n/zh_CN.js"></script>
		<script type="text/javascript">
			var app_shop = {
				datas : {
					ediShop : null,
					currentShopNavSelect: null,
					editor: {},
					shopFactory: {
						nav_active_index: null,
						sec_nav_active_index: null,
						module_active_index: null,
						module_datas: null
					},
				} ,
				shopnav: {
					openShopFactory: function(index){
						app_shop.datas.ediShop = $('#shop-datagrid').datagrid('getRows')[index];
						$('#shopNavWin').window('open');
						$('.shop-factory .shop-factory-container .shop-factory-nav').html('')
						$('.shop-factory .shop-factory-module ul').html('')
						$('.shop-factory .shop-factory-tools > div').hide()
						$('.shop-factory iframe').attr('src', '')
						app_shop.datas.shopFactory = {
							nav_active_index: null,
							sec_nav_active_index: null,
							module_active_index: null,
							module_datas: null
						}
						app_shop.shopnav.loadShopNavs();
					},
					loadShopNavs: function(){
						//初始化数据在这里
						requestServer(commonConfig.shopUrlPrefix() + '/shop/'+app_shop.datas.ediShop.id+'/nav', 'GET').then((response) => {
							if (response.code == 1) {
								app_shop.datas.ediShop.navs = response.datas ; 
								var tab_html = '',
									sec_nav_html = ''
								response.datas.map(function(e, i){
									tab_html += '<li data-index="'+i+'" class="'+(e.isShow ? '' : 'shop-factory-tab-hide')+'">'+e.name+'('+ e.id +')</li>'
								})
								if(tab_html == ''){
									tab_html = '<div onclick="app_shop.shopnav.plusShopNav()">新增</div>'
								}
								// 一级导航
								$('.shop-factory-tab').html('<ul>'+tab_html+'</ul>').find('ul li').on('click', function(){
									$(this).addClass('active').siblings().removeClass('active')
									app_shop.datas.shopFactory.nav_active_index = $(this).data('index')
									app_shop.datas.shopFactory.sec_nav_active_index = null
									app_shop.datas.shopFactory.module_active_index = null
									$('.shop-factory-module').html('')
									// 渲染二级导航列表
									var sec_nav_html = ''
									app_shop.datas.ediShop.navs[app_shop.datas.shopFactory.nav_active_index].childrens.map(function(_e, _i){
										sec_nav_html += '<li data-index="'+_i+'" class="'+(_e.isShow ? '' : 'shop-factory-tab-hide')+'"><img  src="'+_e.thumb+'" /><span>'+_e.name+'</span></li>';
									})
									app_shop.shopnav.changeToolsView(0)
									if(sec_nav_html == ''){
										sec_nav_html = '<div onclick="app_shop.shopnav.plusSecondNav(0)">新增</div>'
									}
									// 二级点击事件
									$('.shop-factory-nav').html(sec_nav_html).find('li').on('click', function(){
										$(this).addClass('active').siblings().removeClass('active')
										app_shop.datas.shopFactory.sec_nav_active_index = $(this).data('index')
										app_shop.datas.shopFactory.module_active_index = null
										// 渲染模块列表
										app_shop.shopnav.getModule(app_shop.datas.ediShop.navs[app_shop.datas.shopFactory.nav_active_index].childrens[app_shop.datas.shopFactory.sec_nav_active_index].id)
										app_shop.shopnav.changeToolsView(1)
									})
								})
								if(app_shop.datas.shopFactory.nav_active_index != null){
									$('.shop-factory-tab ul li').eq(app_shop.datas.shopFactory.nav_active_index).trigger('click')
									if(app_shop.datas.shopFactory.sec_nav_active_index != null){
										$('.shop-factory-nav li').eq(app_shop.datas.shopFactory.sec_nav_active_index).trigger('click')
									}
								}
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					getModule: function(_navId){
						requestServer(commonConfig.shopUrlPrefix() + '/shop/nav/'+ _navId +'/collection', 'GET').then((response) => {
							if (response.code == 1) {
								app_shop.datas.shopFactory.module_datas = response.datas
								var module_html = ''
								response.datas.map(function(e,i){
									module_html += '<li data-index="'+i+'"><img src="'+e.thumb+'" /><div><p>'+e.collectionName+'<small>('+e.comments+')</small></p><p>模块ID:'+e.collectionId+'<small>(优先级:'+e.priority+')</small></p></div></li>'
								})
								// 模块点击
								if(module_html == ''){
									module_html = '<div onclick="app_shop.shopnav.addNavModule()">绑定模块</div>'
								}
								$('.shop-factory-module').html('<ul>' + module_html + '</ul>').find('ul li').on('click', function(){
									$(this).addClass('active').siblings().removeClass('active')
									app_shop.datas.shopFactory.module_active_index = $(this).data('index')
									app_shop.shopnav.changeToolsView(2)
								})
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					changeToolsView: function(type){
						$('.shop-factory-tools .shop-factory-tools-' + type).show().siblings().hide()
					},
					openShopNavEditWin: function(){
						$('#shopNavEdit').dialog('open');
						$('#shop-nav-edit-form .form-item > img').off().click(function(){
							app_shop.datas.uploaderUploadCallBack = app_shop.shopnav.uploadNavThumbCallBack;
							$('#navThumbUpload').trigger('click');
						});
						$('#shop-nav-edit-form').form('clear');
						$('#shop-nav-edit-form .form-item > img').attr('src' , 'dists/super/images/nav_add_holder.png');
					},
					plusSecondNav: function(type){
						var shopNavIndex = app_shop.datas.shopFactory.nav_active_index,
							navIndex = app_shop.datas.shopFactory.sec_nav_active_index;
						// 新增二级导航
						app_shop.datas.v_Result = true;
						app_shop.shopnav.openShopNavEditWin();
						$('#nav-switchbutton').switchbutton('check');
						var _navData = app_shop.datas.ediShop.navs[shopNavIndex]
						$('#shop-nav-edit-form').form('load' , {
							parentId : _navData.id,
							priority : navIndex == null ? 0 : app_shop.datas.ediShop.navs[shopNavIndex].childrens[navIndex].priority
						});
						// 编辑
						if(type == 1){
							try{
								var secondNav = app_shop.datas.ediShop.navs[shopNavIndex].childrens[navIndex];
								$('#shop-nav-edit-form').form('load' , secondNav);
								$('#nav-switchbutton').switchbutton(secondNav.isShow ? 'check' : 'uncheck');
								$('#shop-nav-edit-form .form-item > img').attr('src' , secondNav.thumb);
							}catch(e){console.error(e);}
						}
					},
					openView: function(){
						// 一级菜单的链接
						if(app_shop.datas.shopFactory.nav_active_index == null){
							return
						}
						var _navData = app_shop.datas.ediShop.navs[app_shop.datas.shopFactory.nav_active_index]
						var link = app_shop.datas.ediShop.location + '/item/list.html?id=' + _navData.id
						$('.shop-factory-pageview iframe').attr('src', link)
					},
					deleteSecondNav: function(){
						if(app_shop.datas.shopFactory.nav_active_index == null || app_shop.datas.shopFactory.sec_nav_active_index == null){
							return
						}
						var navId = app_shop.datas.ediShop.navs[app_shop.datas.shopFactory.nav_active_index].childrens[app_shop.datas.shopFactory.sec_nav_active_index].id
						$.messager.confirm('提示', '确认删除?', function(r){
							if (r){
								requestServer(commonConfig.shopUrlPrefix() + '/shop/nav/'+navId, 'DELETE').then((response) => {
									if (response.code == 1) {
										showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
										app_shop.shopnav.loadShopNavs();
									}else {
										$.messager.alert('提示',response.message,'error');
									}
								}).catch((error) => {
									console.log(error)
								});
							}
						});
					},
					saveNavEdit: function(){
						if(app_shop.datas.ediShop == null){
							$.messager.alert('提示','商城信息不存在...','error');
							return ;
						}
						//新增还是修改?用id去判断,一级还是二级?用parentId去判断
						if(!$('#shop-nav-edit-form').form('validate')){
							$.messager.alert('提示','参数信息不完整...','error');
							return ;
						}
						//保存当前所在的TabIndex
						app_shop.datas.currentShopNavSelect = app_shop.datas.shopFactory.nav_active_index
						
						var _formJSON = $('#shop-nav-edit-form').serializeJson();
						_formJSON.isShow = $('#nav-switchbutton').switchbutton("options").checked ; 
						_formJSON.thumb = $('#shop-nav-edit-form .form-item > img').attr('src');
						
						requestBodyServer(commonConfig.shopUrlPrefix() + '/shop/'+app_shop.datas.ediShop.id+'/nav', 'POST', _formJSON).then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
								$('#shopNavEdit').dialog('close');
								app_shop.shopnav.loadShopNavs();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					plusShopNav: function(){
						app_shop.shopnav.openShopNavEditWin();
						$('#nav-switchbutton').switchbutton('check');
						if(app_shop.datas.shopFactory.nav_active_index == null){
							return
						}
						$('#shop-nav-edit-form').form('load' , {
							priority: app_shop.datas.ediShop.navs[app_shop.datas.shopFactory.nav_active_index].priority
						});
					},
					editShopNav:function(){
						if(app_shop.datas.shopFactory.nav_active_index == null){
							return
						}
						app_shop.shopnav.openShopNavEditWin();
						var _navData = app_shop.datas.ediShop.navs[app_shop.datas.shopFactory.nav_active_index]
						// $('#shopNavEdit').dialog('open');
						$('#shop-nav-edit-form').form('load' , _navData);
						$('#nav-switchbutton').switchbutton(_navData.isShow ? 'check' : 'uncheck');
						$('#shop-nav-edit-form .form-item > img').attr('src' , _navData.thumb);
					},
					deleteShopNav: function(){
						if(app_shop.datas.shopFactory.nav_active_index == null){
							return
						}
						$.messager.confirm('提示', '确认删除?', function(r){
							if (r){
								var _navData = app_shop.datas.ediShop.navs[app_shop.datas.shopFactory.nav_active_index]
								requestServer(commonConfig.shopUrlPrefix() + '/shop/nav/'+_navData.id, 'DELETE').then((response) => {
									if (response.code == 1) {
										showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
										app_shop.datas.currentShopNavSelect = null;
										app_shop.shopnav.loadShopNavs();
									}else {
										$.messager.alert('提示',response.message,'error');
									}
								}).catch((error) => {
									console.log(error)
								});
							}
						});
					},
					copyShopNavLink: function(){
						// 复制一级菜单的链接
						if(app_shop.datas.shopFactory.nav_active_index == null){
							return
						}
						var _navData = app_shop.datas.ediShop.navs[app_shop.datas.shopFactory.nav_active_index]
						var link = app_shop.datas.ediShop.location + '/item/list.html?id=' + _navData.id + '&anavId='
						tools.copyToClipboard(link)
					},
					deleteNavModule: function(){
						var id = app_shop.datas.shopFactory.module_datas[app_shop.datas.shopFactory.module_active_index].id
						$.messager.confirm('提示', '确认删除?', function(r){
							if (r){
								requestServer(commonConfig.shopUrlPrefix() + '/shop/nav/collection/'+id, 'DELETE').then((response) => {
									if (response.code == 1) {
										showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
										$('.shop-factory-nav li').eq(app_shop.datas.shopFactory.sec_nav_active_index).trigger('click')
									}else {
										$.messager.alert('提示',response.message,'error');
									}
								}).catch((error) => {
									console.log(error)
								});
							}
						});
					},
					priorityNavModule: function(){
						var navid = app_shop.datas.ediShop.navs[app_shop.datas.shopFactory.nav_active_index].childrens[app_shop.datas.shopFactory.sec_nav_active_index].id
						var collectionId = app_shop.datas.shopFactory.module_datas[app_shop.datas.shopFactory.module_active_index].collectionId
						$.messager.prompt('优先级', '优先级:', function(r){
							if (r){
								requestBodyServer(commonConfig.shopUrlPrefix() + '/shop/nav/collection', 'POST' , {
									navId: navid , 
									collectionId: collectionId , 
									priority: r
								}).then((response) => {
									if (response.code == 1) {
										showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
										$('.shop-factory-nav li').eq(app_shop.datas.shopFactory.sec_nav_active_index).trigger('click')
									}else {
										$.messager.alert('提示',response.message,'error');
									}
								}).catch((error) => {
									console.log(error)
								});
							}
						});
					},
					addNavModule: function(navId){
						$('#navAddModuleWin').window('open');
						$('#navModuleDatagrid').datagrid({
							height: 580,
						    url: commonConfig.shopUrlPrefix() + '/colletion',
							idField: 'collectionId',
						    columns:[[
						    	{field:'ck',checkbox:true,align:'center'},
								{field:'collectionId',title:'模块ID',width:50,align:'center'},
								{field:'name',title:'模块名称',width:100,align:'center'},
								{field:'comments',title:'模块备注',width:120,align:'center'},
								{field:'thumb',title:'呈现方式',width:80,align:'center',formatter: function(value,row,index){
									   return '<img class="td-img" src="'+ value +'">';
								}},
								{field:'banners',title:'banners',width:150,align:'center',formatter: function(value,row,index){
									if(!value || value.length == 0) return '无' ;
									
									var _html = '' ; 
									var _values = value.split(';');
									$.each(_values, function(index , _value) {
										if(_value && _value.length > 0){
											_html += '<img class="td-img" src="'+ _value.split('@#@')[0] +'">';
										}
									});
									if(_html == '') return '无';
									 return '<div class="banner-images">'+_html+'</div>';
								}},
								{field:'productCount',title:'产品数量',width:50,align:'center'}
						    ]]
						});
						$('#navModuleDatagrid').datagrid('clearChecked');
					},
					persitsNavModules: function(){
						var _modules = $('#navModuleDatagrid').datagrid('getChecked');
						if(_modules.length == 0){
							$.messager.alert('提示' , '没有选择数据...' , 'error');
							return;
						}
						var priority = app_shop.datas.shopFactory.module_active_index ? app_shop.datas.shopFactory.module_datas[app_shop.datas.shopFactory.module_active_index].priority : 0
						var _navigationCollections = [] ; 
						$.each(_modules, function(index , _module) {
							_navigationCollections.push({
								navId: app_shop.datas.ediShop.navs[app_shop.datas.shopFactory.nav_active_index].childrens[app_shop.datas.shopFactory.sec_nav_active_index].id , 
								collectionId: _module.collectionId, 
								priority: priority
							});
						});
						
						requestBodyServer(commonConfig.shopUrlPrefix() + '/shop/nav/collections', 'POST' , _navigationCollections).then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
								$('.shop-factory-nav li').eq(app_shop.datas.shopFactory.sec_nav_active_index).trigger('click')
								$('#navAddModuleWin').window('close');
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					uploadNavThumbCallBack: function(result){
						$('#shop-nav-edit-form .form-item > img.mav-thumb').attr('src' , JSON.parse(result.response).datas[0]);
					},
					initUpload: function () {
	                    app_shop.datas.uploaderUpload = new plupload.Uploader({
	                        runtimes: 'html5,html4',
	                        browse_button: 'navThumbUpload',
	                        url: commonConfig.shopUrlPrefix() + '/upload/image',
	                        file_data_name: 'images',
	                        filters: {
	                            max_file_size: '1024kb',
	                            mime_types: [
	                                {title : "Image files", extensions : "jpg,gif,png"}
	                            ],
	                        },
	                        multipart_params: {
	                            //access_token: utils.cookie.getCookie('accessToken')
	                        },
	                        init: {
	                            FilesAdded: function (up, files) {
	                                up.start();
	                            },
	                            FileUploaded: function(up, files, result){
	                            	app_shop.datas.uploaderUploadCallBack(result);
                            	},
	                            UploadComplete: function (up, files) {
	                            },
	                            Error: function (up, err) {
	                            	$.messager.alert('提示',JSON.parse(err.response).body.message,'error');
	                            }
	                        }
	                    });
	                    app_shop.datas.uploaderUpload.init();
	                }
				},
				methods : {
					initDatagrid : function(){
						$('#shop-datagrid').datagrid({
							height: $(document).height() - 200,
						    url: commonConfig.shopUrlPrefix() + '/shop',
						    pagination: false,
						    columns:[[
								{field:'name',title:'名称',width:100,align:'center', formatter:function(value,row,index){
									return '<a href="javascript:;" onclick="app_shop.shopnav.openShopFactory('+index+');">'+value+'</a>'
								}},
								{field:'logo',title:'主图',width:60,align:'center',formatter: function(value,row,index){
										return  '<img class="td-img" src="'+ (value || "dists/super/images/nav_add_holder.png") +'" onclick="app_shop.methods.changeShopLogo('+ index +')">';
									}
								},
								{field:'location',title:'地址',width:150,align:'center',formatter: function(value,row,index){
									return '<a href="'+value+'" target="_blank">'+value+'</a>';
								}},
								{field:'comments',title:'备注',width:150,align:'center'},
								{field:'prefix',title:'订单前缀',width:60,align:'center'},
								{field:'currency',title:'币种',width:80,align:'center'},
								{field:'currencySymbol',title:'币种符号',width:80,align:'center'},
								{field:'exchangeRate',title:'汇率',width:80,align:'center'},
								{field:'basicPrice',title:'包邮价格',width:80,align:'center'},
								{field:'freight',title:'运费',width:50,align:'center'},
								{field:'options',title:'操作',width:80,align:'center',formatter: function(value,row,index){
									   return '<button class="row-btn info" onclick="app_shop.methods.editShop('+index+');">编辑</button><button class="row-btn primary" onclick="app_shop.methods.deleteShop('+row.id+');">删除</button>';
								}}
								
						    ]]
						});
					},
					changeShopLogo: function(index){
						app_shop.datas.changeShopLogoIndex = index ;
						app_shop.datas.uploaderUploadCallBack = app_shop.methods.changeShopLogoCallback;
						$('#navThumbUpload').trigger('click');
						
					},
					changeShopLogoCallback: function(result){
						var _logo = JSON.parse(result.response).datas[0] ; 
						var _selectRow = $('#shop-datagrid').datagrid('getRows')[app_shop.datas.changeShopLogoIndex];
						//TODO
						requestBodyServer(commonConfig.shopUrlPrefix() + '/shop/logo', 'PUT', {id: _selectRow.id , logo: _logo}).then((response) => {
							if (response.code == 1) {
								app_shop.methods.queryDatagrid();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					openCreateShopWindow: function(){
						$('#shopEditWin').window('open');
						$('#shopEditForm').form('clear');
						
						//TODO
						if(app_shop.datas.editor.E == null){
							app_shop.datas.editor.E = window.wangEditor;
						}
						if(app_shop.datas.editor.aboutUsEditor == null){
							app_shop.datas.editor.aboutUsEditor = new app_shop.datas.editor.E('#aboutUs');
							app_shop.datas.editor.aboutUsEditor.customConfig.menus = ['head','bold','fontSize','fontName','italic','underline','strikeThrough','foreColor','backColor','link','justify','quote','table','code','undo','redo'];
							app_shop.datas.editor.aboutUsEditor.create();
						}
						if(app_shop.datas.editor.privacyPolicyEditor == null){
							app_shop.datas.editor.privacyPolicyEditor = new app_shop.datas.editor.E('#privacyPolicy');
							app_shop.datas.editor.privacyPolicyEditor.customConfig.menus = ['head','bold','fontSize','fontName','italic','underline','strikeThrough','foreColor','backColor','link','justify','quote','table','code','undo','redo'];
							app_shop.datas.editor.privacyPolicyEditor.create();
						}
						if(app_shop.datas.editor.exchangePolicyEditor == null){
							app_shop.datas.editor.exchangePolicyEditor = new app_shop.datas.editor.E('#exchangePolicy');
							app_shop.datas.editor.exchangePolicyEditor.customConfig.menus = ['head','bold','fontSize','fontName','italic','underline','strikeThrough','foreColor','backColor','link','justify','quote','table','code','undo','redo'];
							app_shop.datas.editor.exchangePolicyEditor.create();
						}
						if(app_shop.datas.editor.problemsEditor == null){
							app_shop.datas.editor.problemsEditor = new app_shop.datas.editor.E('#problems');
							app_shop.datas.editor.problemsEditor.customConfig.menus = ['head','bold','fontSize','fontName','italic','underline','strikeThrough','foreColor','backColor','link','justify','quote','table','code','undo','redo'];
							app_shop.datas.editor.problemsEditor.create();
						}
						
						app_shop.datas.editor.aboutUsEditor.txt.clear();
						app_shop.datas.editor.privacyPolicyEditor.txt.clear();
						app_shop.datas.editor.exchangePolicyEditor.txt.clear();
						app_shop.datas.editor.problemsEditor.txt.clear();
						
					},
					createShop: function(){
						$('#shopEditWin').window('close');
						var _formData = $('#shopEditForm').serializeJson();
						_formData.aboutUs = app_shop.datas.editor.aboutUsEditor.txt.html();
						_formData.privacyPolicy = app_shop.datas.editor.privacyPolicyEditor.txt.html();
						_formData.exchangePolicy = app_shop.datas.editor.exchangePolicyEditor.txt.html();
						_formData.problems = app_shop.datas.editor.problemsEditor.txt.html();
						requestBodyServer(commonConfig.shopUrlPrefix() + '/shop', 'POST', _formData).then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
								app_shop.methods.queryDatagrid();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					editShop: function(rowIndex){
						app_shop.methods.openCreateShopWindow();
						var rowData = $('#shop-datagrid').datagrid('getRows')[rowIndex] ; 
						$('#shopEditForm').form('load' , rowData);
						//TODO
						if(app_shop.datas.editor.E == null){
							app_shop.datas.editor.E = window.wangEditor;
						}
						if(app_shop.datas.editor.aboutUsEditor == null){
							app_shop.datas.editor.aboutUsEditor = new app_shop.datas.editor.E('#aboutUs');
							app_shop.datas.editor.aboutUsEditor.customConfig.menus = ['head','bold','fontSize','fontName','italic','underline','strikeThrough','foreColor','backColor','justify','quote','table','code','undo','redo'];
							app_shop.datas.editor.aboutUsEditor.create();
						}
						if(app_shop.datas.editor.privacyPolicyEditor == null){
							app_shop.datas.editor.privacyPolicyEditor = new app_shop.datas.editor.E('#privacyPolicy');
							app_shop.datas.editor.privacyPolicyEditor.customConfig.menus = ['head','bold','fontSize','fontName','italic','underline','strikeThrough','foreColor','backColor','justify','quote','table','code','undo','redo'];
							app_shop.datas.editor.privacyPolicyEditor.create();
						}
						if(app_shop.datas.editor.exchangePolicyEditor == null){
							app_shop.datas.editor.exchangePolicyEditor = new app_shop.datas.editor.E('#exchangePolicy');
							app_shop.datas.editor.exchangePolicyEditor.customConfig.menus = ['head','bold','fontSize','fontName','italic','underline','strikeThrough','foreColor','backColor','justify','quote','table','code','undo','redo'];
							app_shop.datas.editor.exchangePolicyEditor.create();
						}
						if(app_shop.datas.editor.problemsEditor == null){
							app_shop.datas.editor.problemsEditor = new app_shop.datas.editor.E('#problems');
							app_shop.datas.editor.problemsEditor.customConfig.menus = ['head','bold','fontSize','fontName','italic','underline','strikeThrough','foreColor','backColor','justify','quote','table','code','undo','redo'];
							app_shop.datas.editor.problemsEditor.create();
						}
						
						app_shop.datas.editor.aboutUsEditor.txt.html(rowData.aboutUs);
						app_shop.datas.editor.privacyPolicyEditor.txt.html(rowData.privacyPolicy);
						app_shop.datas.editor.exchangePolicyEditor.txt.html(rowData.exchangePolicy);
						app_shop.datas.editor.problemsEditor.txt.html(rowData.problems);
					},
					deleteShop: function(shopId){
						$.messager.confirm('提示', '确定删除?', function(r){
							if (r){
								requestServer(commonConfig.shopUrlPrefix() + '/shop/' + shopId, 'DELETE').then((response) => {
									if (response.code == 1) {
										showMessage('<i class="fa fa-info-circle"></i>&nbsp; 删除成功...');
										app_shop.methods.queryDatagrid();
									}else {
										$.messager.alert('提示',response.message,'error');
									}
								}).catch((error) => {
									console.log(error)
								});
							}
						});
					},
					showSKU: function(index){
						$('#orderSkuDetais').window('open');
						$('#orderSkuDetais-datagrid').datagrid({
							data: $('#shop-datagrid').datagrid('getRows')[index].orderSkuDTOs,
							pagination:false,
						    columns:[[
						    	{field:'productId',title:'产品ID',width:80,align:'center'},
								{field:'productSkuBarcode',title:'产品编码',width:100,align:'center'},
								{field:'productImageUrl',title:'产品图片',width:60,align:'center',formatter:function(value,row,index){return '<img class="td-img" src="'+ value +'">';}},
								{field:'productTitle',title:'产品名称',width:120,align:'center'},
								{field:'productSkuName',title:'产品规格',width:100,align:'center'},
								{field:'productPrice',title:'价格',width:80,align:'center'},
								{field:'quantity',title:'数量',width:80,align:'center'}
						    ]]
						});
						
					},
					queryDatagrid: function(){
						$('#shop-datagrid').datagrid('reload');
					}
				},
				init : function(){
					app_shop.methods.initDatagrid();
					app_shop.shopnav.initUpload();
				}
			}
			app_shop.init();
		</script>
	</body>
</html>
